<?php
class profiles_model extends CI_Model {
	var $table_name = 'student_profiles';
    var $title   = '';
    var $content = '';
    var $date    = '';

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    function view_entry ()
    {
		$table_name = $this->table_name;
		// $student_id = intval ($_GET['student_id']);
		$student_id = 1;
		$query = $this->db->query ("SELECT * FROM $table_name WHERE student_id='$student_id' LIMIT 1");
        return $query->result ();
    }

    function browse_entry ()
    {
		$table_name = $this->table_name;
		$query = $this->db->get ($table_name, 23);
        return $query->result ();
    }

    function insert_entry()
    {
		$this->title   = $_POST['title']; // please read the below note
        $this->content = $_POST['content'];
        $this->date    = time();

        $this->db->insert('entries', $this);
    }

    function update_entry()
    {
        $this->title   = $_POST['title'];
        $this->content = $_POST['content'];
        $this->date    = time();

        $this->db->update('entries', $this, array('id' => $_POST['id']));
    }

}
?>